#ifndef THREEDCUBEGAME_H
#define THREEDCUBEGAME_H

#include "BaseGameEngine.h"

class ThreeDCubeGame :
	public BaseGameEngine
{
public:
	ThreeDCubeGame();

	// Do any setup of back buffer prior to locking the screen buffer
	// Basically do the drawing of the background in here and it'll be copied to the screen for you as needed
	virtual void SetupBackgroundBuffer();

	// Create the bouncing ball(s)
	int InitialiseObjects();

	// Ensure that pressing a key alters the speed
	virtual void KeyDown(int iKeyCode);

	/**
	Draw a cube within a rectangular space, with the top-left corner at a specific position.
	If bCopyPixelsAndRedraw is true then the background is copied to the foreground and the screen is redrawn.
	*/
	void DrawCube( int iXOffset, int iYOffset, bool bCopyPixelsAndRedraw, char tileColour );

	/** X-offset for the map */
	static const int MAP_X_OFFSET = 15;
	/** Y-offset for the map */
	static const int MAP_Y_OFFSET = 80;

	/** Width of the map - in tiles*/
	static const int MAP_WIDTH = 34;
	/** Height of the map - in tiles*/

	//changed from 10 to 8 to make game tougher with smaller map
	static const int MAP_HEIGHT = 8;

	/** Block size - tiles are 3 blocks high and 2 blocks wide */
	static const int BLOCK_SIZE = 30;

	/** Get the map information for a location */
	inline char GetMapEntry( int iMapX, int iMapY ) { return m_acMapData[iMapX][iMapY]; }

	/** Set the map information for a location */
	inline void SetMapEntry( int iMapX, int iMapY, char cNew ) { m_acMapData[iMapX][iMapY] = cNew; }

	inline void RecordColourChanged() 
	{ 
		m_iColourChangesLeft--;
	}

	/** Get a screen X coordinate from a tile coordinate.
		Note that only alternate positions on the map are set - others are not used */
	inline int GetScreenXForMapX( int iScreenX ) { return MAP_X_OFFSET+BLOCK_SIZE*iScreenX; }

	

	/** Get a screen Y coordinate from a tile coordinate.
		Note that only alternate positions on the map are set - others are not used */
	inline int GetScreenYForMapY( int iScreenY ) { return MAP_Y_OFFSET+BLOCK_SIZE*2*iScreenY; }
	bool m_bPaused;
	void DrawScreen();
	void DrawStrings();
	int m_iLivesLeft;
	static const int NUMBER_MAPS = 3;
	void InitMap();
	int m_iLevelNumber;
	int m_iScore;
	//used to give duration of power if status is true
	int m_iPowerTime;
	bool m_iPowerStatus;
	//used to give duration of immunity if status is true
	int m_iImmunityTime;
	bool m_iImmunityStatus;
	//used to give duration that opponenets are frozen if status is true
	int m_iFreezeTime;
	bool m_iFreezeStatus;
	//variable which returns which pausescreen to display
	int pausetype;
	//used if hyperspeed cube is jumped on. opponents move faster
	bool m_iHyperSpeed;
	int temp;

private:
	/** Map data: */
	char m_acMapData[MAP_WIDTH][MAP_HEIGHT];
	//how many cube colours to change to complete current level
	int m_iColourChangesLeft;
	//static char mapdata[NUMBER_MAPS][274];

public:
	void GameAction();
	void InitialiseLevel();
	//used to load a map from file
	void LoadFile();
	//used to obtain bonus points tile
	bool PowerUp(bool m_iPowerStatus);
	//used to grant player with immunity
	bool Immunity(bool m_iImmunityStatus);
	//used to grant player with freeze enemy power
	bool FreezeEnemy(bool m_iFreezeStatus);
	void SetHiScore();
	int GetHiScore();
};

#endif
